package com.jt.admin.controller;

import com.jt.admin.common.utils.R;
import com.jt.admin.common.utils.ServletUtils;
import com.jt.admin.domain.entity.SysUserEntity;
import com.jt.admin.domain.model.LoginBody;
import com.jt.admin.domain.model.LoginUser;
import com.jt.admin.service.SysLoginService;
import com.jt.admin.service.TokenService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class SysLoginController {
    @Autowired
    SysLoginService sysLoginService;

    @Autowired
    private TokenService tokenService;

    /**
     * 登录
     * @param loginBody
     * @return
     */
    @PostMapping("/login")
    public R login(@RequestBody LoginBody loginBody){
        String token= sysLoginService.login(loginBody);
        return R.success().put("token",token);
    }

    /**
     * 获取登录用户信息
     * @return
     */
    @GetMapping("/userInfo")
    public R getInfo(){
        return sysLoginService.getUserInfo();
    }
}
